package com.longge.wechat.message.menu;

import com.longge.wechat.message.wxUtil.WeiXinUtil;


public class MenuManager {

	public static void main(String[] args) {
		// 调用接口创建菜单
		int result = WeiXinUtil.createMenu(getMenu());

		// 判断菜单创建结果
		if (0 == result)
			System.out.println("菜单创建成功！");
		else
			System.out.println("菜单创建失败，错误码：" + result);
		
	}
	
	
	/**
	 * 组装菜单数据
	 * 
	 * @return menu
	 */
	private static Menu getMenu() {
		CommonButton mainBtn1 = new CommonButton();
		mainBtn1.setName("语音识别");
		mainBtn1.setType("click");
		mainBtn1.setKey("value_1");

		CommonButton btn21 = new CommonButton();
		btn21.setName("语音");
		btn21.setType("click");
		btn21.setKey("value_21");

		CommonButton btn22 = new CommonButton();
		btn22.setName("图片");
		btn22.setType("click");
		btn22.setKey("value_22");

		CommonButton btn23 = new CommonButton();
		btn23.setName("文字");
		btn23.setType("click");
		btn23.setKey("value_23");


		CommonButton mainBtn3 = new CommonButton();
		mainBtn3.setName("获取信息");
		mainBtn3.setType("click");
		mainBtn3.setKey("value_3");
		
		ComplexButton mainBtn2 = new ComplexButton();
		mainBtn2.setName("客服接口");
		mainBtn2.setSub_button(new CommonButton[] { btn21, btn22, btn23});

		//按钮数组组装成菜单
		Menu menu = new Menu();
		menu.setButton(new Button[] { mainBtn1, mainBtn2, mainBtn3 });

		return menu;
	}

}
